/**
 * Created by x298017064010 on 17/3/23.
 */

import Vuex from 'vuex'

import * as mutations from './mutations'
import * as actions from './actions'
import * as getters from './getters'

import TodoModule from './modules/TodoModule'

// Vuex is auto installed on the web
if (WXEnvironment.platform !== 'Web') {
    Vue.use(Vuex)
}

const dom = weex.requireModule('dom');
dom.getComponentRect("viewport", option => {
    var {width, height} = option.size;
    store.state.deviceWidth = width;
    store.state.deviceHeight = height;
});

const store = new Vuex.Store({

    mutations: mutations,
    actions: actions,
    getters: getters,
    modules: {
        todo: TodoModule,
    },

    // 初始化整个应用状态 this.$store.state.count
    state: {
        count: 0,
        deviceWidth: 0,
        deviceHeight: 0,
    }
});

export default store